<?php
require 'include/global.php';
require './include/validate.php';
require './include/all_left.php';
include("FCKeditor/fckeditor.php") ;

require_once 'include/advisory_db.php';
$smarty->compile_check = true;

$smarty->display('header.tpl');
$smarty->display('allleft.tpl');
      
if($_GET[rid]){
	$sql = "SELECT a.*,b.jo_id,b.jo_uid,b.jo_title FROM pa_contact as a, pa_job as b WHERE a.re_aliasid = b.jo_id AND a.re_id = '".$_GET[rid]."' AND ( b.jo_uid = '".$_SESSION['uid']."' OR a.re_uid = '".$_SESSION['uid']."' )";
	$_POST = $DB->fetch_one_array($sql);
	$rid = $_GET[rid];
}

if(empty($_POST)){
	$smarty->compile_check = true;

   $err = "You are not authorized to view this page.";
   $smarty->assign("err",$err);
   $smarty->display("error.tpl");
   $smarty->display("allright.tpl");
   $smarty->display('footer.tpl');
   exit;
}

$re_fname = $_POST[re_fname];
$re_lname = $_POST[re_lname];
$re_email = $_POST[re_email];
$re_email_full = "<a href='mailto:".$_POST[re_email]."'>".$_POST[re_email]."</a>";
$re_address1 = $_POST[re_address1];
$re_address2 = $_POST[re_address2];
$re_lostate = $_POST[re_lostate];
$re_locountry = $_POST[re_locountry];
$re_locity = $_POST[re_locity];
$re_phone1 = $_POST[re_phone1];
$re_phone2 = $_POST[re_phone2];
$re_jobtype = $_POST[re_jobtype];
$re_jobindustry = $_POST[re_jobindustry];
$re_jobtitle = $_POST[re_jobtitle];
$re_yearexp = $_POST[re_yearexp];
$re_edulevel = $_POST[re_edulevel];
$re_proflicense = $_POST[re_proflicense];
$re_mgmt = $_POST[re_mgmt];
$re_profit = $_POST[re_profit];
$re_spoken = $_POST[re_spoken];
$re_prolang = $_POST[re_prolang];
$re_ip = $_POST[re_ip];
$re_ussecurity = $_POST[re_ussecurity];
$re_authorize = $_POST[re_authorize];
$re_subject = $_POST[re_subject];
$re_detail = $_POST[re_detail];
$re_comments = $_POST[re_comments];
$re_regtime  = $_POST[re_regtime];
$re_upload   = $_POST[re_upload];
$re_jobsearchstatus = $_POST[re_jobsearchstatus];
$re_describeme = $_POST[re_describeme];
$re_favoriatebook = $_POST[re_favoriatebook];
$re_highachieve = $_POST[re_highachieve];
$re_iplan = $_POST[re_iplan];
$re_iliketo = $_POST[re_iliketo];
$re_comments = $_POST[re_comments];
$re_prvemployer = $_POST[re_prvemployer];
$re_prvempstatus = $_POST[re_prvempstatus];
$re_professavilable = $_POST[re_professavilable];
$re_currentpay  = $_POST[re_currentpay];
$re_desiredpay= $_POST[re_desiredpay];
$re_benefits= $_POST[re_benefits];
$re_schoolattend= $_POST[re_schoolattend];
$re_personalweb = $_POST[re_personalweb];
$re_private     = $_POST[re_private];
$re_updtime     = $_POST[re_updtime];
$re_sponsorship = $_POST[re_sponsorship];

 
ob_clean();
ob_start();

$regtime = date("m-d-Y",$_POST['re_regtime']);
$from = $_POST['re_fname'] ." ". $_POST['re_lname'];
$subject = ($_POST['re_subject'] != '')?'<b><font color="blue">'.$_POST['re_subject']."</font><b>":"N/A";

$sql = "SELECT jo_utype FROM pa_job WHERE jo_id = '".$_POST['jo_id']."'";
$jobOwnerInfo = $DB->fetch_one_array($sql);
if($jobOwnerInfo['jo_utype'] == 'recruiter'){
	$sql = "SELECT rc_fname, rc_lname, rc_copname, rc_email FROM  pa_recuiter WHERE rc_id = '".$_POST['jo_uid']."'";
	$recInfo = $DB->fetch_one_array($sql);
}


echo '
<table width="580" border="0" cellpadding="5" cellspacing="5" style="border:#C7C7C7 solid 1px;" class="inputcontrol2">
<tr><td width="25%" >
					Date:</td>
                       <td  width="70%" ><b>'.$regtime.'</b></td>
                   </tr>
<tr><td width="25%" >
					From:</td>
                       <td  width="70%" ><b>'.$from.'</b></td>
                   </tr>
<tr><td width="25%" >
					Subject:</td>
                       <td  width="70%" ><div style="border:1px solid grey;width:350px">'.$subject.'</div></td>
                   </tr>
<tr><td width="25%" >
					Sent To:</td>
                       <td  width="70%" >'.$recInfo['rc_copname'].'</td>
                   </tr>
<tr><td width="25%" >
					Job Req# :</td>
                       <td  width="70%" >'.$_POST['jo_id'].'</td>
                   </tr>
<tr><td width="25%" >
					Job Title:</td>
                       <td  width="70%" > '.$_POST['jo_title'].'</td>
                   </tr>
<tr><td width="25%"  >
				              Message:  </td><td width="70%" ><div style="border:1px solid grey"> '.$_POST['re_detail'].' </div>
							 </td>
					   </tr>';
if(trim($_POST[re_upload]) != ''){
echo '<tr><td width="25%"  >
		  Attach Document:  </td><td width="70%" > <a href="./uploadfiles/contact/'.trim($_POST['re_upload']).'">View</a>
		 </td>
   </tr>';
}

echo '<tr class="tbhead">
		<td  align="center" colspan="2">
		<input class="bginput button-secondary" type="button" onclick="history.go(-1)" value=" Close " />';
if($_SESSION['uid'] != $_POST['re_uid']){
		echo '<input class="bginput button-secondary" type="button" onclick="location.href=\'contactreply.php?rid='.$rid.'\'" value=" Reply " />';
}
		
echo		'</td>
		</tr>
		</table>
		';

$reg_data = ob_get_contents();
ob_end_clean();

if ($err != '')
{
	$smarty->assign("err", $err);
}
$smarty->assign("reg", $reg_data);

$title   = "View Message";
$smarty->assign('title',$title);

$smarty->display('contactreg.tpl');


$smarty->display('allright.tpl');
$smarty->display('footer.tpl');
?>
